package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 违规处罚记录
 * </p>
 *
 * @author dqq
 * @date 2022-12-06
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ViolationRecordViolationStatusEnum", description = "处罚状态 #{HAS_EFFECT:已生效;HAS_DEDUCT:已扣除;CANCEL:已撤销-枚举")
public enum ViolationRecordViolationStatusEnum implements BaseEnum {

    /**
     * HAS_EFFECT="已生效"
     */
    HAS_EFFECT("已生效"),
    /**
     * HAS_DEDUCT="已扣除"
     */
    HAS_DEDUCT("已扣除"),
    /**
     * CANCEL="已撤销"
     */
    CANCEL("已撤销"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ViolationRecordViolationStatusEnum match(String val, ViolationRecordViolationStatusEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ViolationRecordViolationStatusEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ViolationRecordViolationStatusEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "HAS_EFFECT,HAS_DEDUCT,CANCEL", example = "HAS_EFFECT")
    public String getCode() {
        return this.name();
    }

}
